package com.xyz.controller;

import com.xyz.aop.ObjectParam;
import com.xyz.aop.Param;
import com.xyz.dto.BusinessAnnounceDto;
import com.xyz.dto.EmContainerDto;
import com.xyz.dto.EmPipingDto;
import com.xyz.dto.SpecialPageAllDto;
import com.xyz.service.AnnounceService;
import com.xyz.service.SpecialEmService;
import com.xyz.service.SystemService;
import com.xyz.util.dto.DataResult;
import com.xyz.util.dto.LoginInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("specialEm")
public class SpecialEmController {

    private static final Logger logger = LoggerFactory.getLogger(SpecialEmController.class);

    @Autowired
    private SpecialEmService specialEmService;

    @PostMapping("/getEmPipingList")
    public DataResult getEmPipingList(LoginInfo loginInfo,@ObjectParam SpecialPageAllDto specialPageAllDto) {
        try {
            return specialEmService.getEmPipingList(loginInfo,specialPageAllDto);
        } catch (Exception e) {
            logger.error("getEmPipingList", e);
            return DataResult.build9500();
        }
    }

    @PostMapping("/insertEmPiping")
    public DataResult insertEmPiping(LoginInfo loginInfo,@ObjectParam EmPipingDto emPipingDto) {
        try {
            return specialEmService.insertEmPiping(loginInfo,emPipingDto);
        } catch (Exception e) {
            logger.error("insertEmPiping", e);
            return DataResult.build9500();
        }
    }

    @PostMapping("/updateEmPiping")
    public DataResult updateEmPiping(LoginInfo loginInfo,@ObjectParam EmPipingDto emPipingDto) {
        try {
            return specialEmService.updateEmPiping(loginInfo,emPipingDto);
        } catch (Exception e) {
            logger.error("updateEmPiping", e);
            return DataResult.build9500();
        }
    }

    @PostMapping("/getEmPipingById")
    public DataResult getEmPipingById(
            LoginInfo loginInfo,
            @Param(type = Param.ParamType.POSITIVE_INTEGER) String id
    ) {
        try {
            return specialEmService.getEmPipingById(loginInfo,id);
        } catch (Exception e) {
            logger.error("getEmPipingById", e);
            return DataResult.build9500();
        }
    }

    @PostMapping("/deleteEmPiping")
    public DataResult deleteEmPiping(
            LoginInfo loginInfo,
            @Param(type = Param.ParamType.POSITIVE_INTEGER) String id
    ) {
        try {
            return specialEmService.deleteEmPiping(loginInfo,id);
        } catch (Exception e) {
            logger.error("deleteEmPiping", e);
            return DataResult.build9500();
        }
    }


    @PostMapping("/getEmContainerList")
    public DataResult getEmContainerList(LoginInfo loginInfo,@ObjectParam SpecialPageAllDto specialPageAllDto) {
        try {
            return specialEmService.getEmContainerList(loginInfo,specialPageAllDto);
        } catch (Exception e) {
            logger.error("getEmContainerList", e);
            return DataResult.build9500();
        }
    }

    @PostMapping("/insertEmContainer")
    public DataResult insertEmContainer(LoginInfo loginInfo,@ObjectParam EmContainerDto emContainerDto) {
        try {
            return specialEmService.insertEmContainer(loginInfo,emContainerDto);
        } catch (Exception e) {
            logger.error("insertEmContainer", e);
            return DataResult.build9500();
        }
    }

    @PostMapping("/updateEmContainer")
    public DataResult updateEmContainer(LoginInfo loginInfo,@ObjectParam EmContainerDto emContainerDto) {
        try {
            return specialEmService.updateEmContainer(loginInfo,emContainerDto);
        } catch (Exception e) {
            logger.error("updateEmContainer", e);
            return DataResult.build9500();
        }
    }

    @PostMapping("/getEmContainerById")
    public DataResult getEmContainerById(
            LoginInfo loginInfo,
            @Param(type = Param.ParamType.POSITIVE_INTEGER) String id
    ) {
        try {
            return specialEmService.getEmContainerById(loginInfo,id);
        } catch (Exception e) {
            logger.error("getEmContainerById", e);
            return DataResult.build9500();
        }
    }

    @PostMapping("/deleteEmContainer")
    public DataResult deleteEmContainer(
            LoginInfo loginInfo,
            @Param(type = Param.ParamType.POSITIVE_INTEGER) String id
    ) {
        try {
            return specialEmService.deleteEmContainer(loginInfo,id);
        } catch (Exception e) {
            logger.error("deleteEmContainer", e);
            return DataResult.build9500();
        }
    }
}
